
#include "loginwindow.h"
#include "ui_loginwindow.h"
#include "usermanager.h"

LoginWindow::LoginWindow(QWidget *parent)
    : QDialog(parent)
    , ui(new Ui::LoginWindow)
{
    ui->setupUi(this);
}

LoginWindow::~LoginWindow()
{
    delete ui;
}

void LoginWindow::on_loginButton_clicked()
{
    QString username = ui->usernameLineEdit->text();
    QString password = ui->passwordLineEdit->text();

    UserManager userManager;
    if (userManager.login(username, password)) {
        emit loginSuccess(username);
        accept();
    } else {
        ui->statusLabel->setText("Login failed. Please try again.");
    }
}
